﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--
 -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<link rel="stylesheet" type="text/css" href="/baseproject/css/component/alert/lhgdialog.css">
	<script type="text/javascript">
var W = frameElement._dlgargs.win;
function A(){ return frameElement._dlgargs; }

window.focus(); W.tool.regdoll(window);

var recontze = function()
{
    var h = $('contain').offsetHeight; h -= $('dtit').offsetHeight;
	h -= $('dfoot').offsetHeight; $('dinner').style.height = Math.max( h, 0 ) + 'px';
}

var drag = function()
{
    var regwin = [], lacoor, curpos;
	
	var cluphdl = function()
	{
	    for( var i = 0; i < regwin.length; i++ )
		{
		    W.tool.remevt( regwin[i].document, 'mousemove', dragmovehdl );
			W.tool.remevt( regwin[i].document, 'mouseup', draguphdl );
		}
	};
	
	var dragmovehdl = function(evt)
	{
	    if(!lacoor) return;
		if(!evt) evt = W.tool.getedoc(this).parentWindow.event;
		
		var curcoor = { x : evt.screenX, y : evt.screenY };
		curpos =
		{
		    x : curpos.x + ( curcoor.x - lacoor.x ),
			y : curpos.y + ( curcoor.y - lacoor.y )
		};
		lacoor = curcoor;
		
		frameElement.style.left	= curpos.x + 'px';
		frameElement.style.top	= curpos.y + 'px';
		
		if(evt.preventDefault) evt.preventDefault(); else evt.returnValue = false;
	};
	
	var draguphdl = function(evt)
	{
	    if(!lacoor) return;
		if(!evt) evt = W.tool.getedoc(this).parentWindow.event;
		cluphdl(); lacoor = null;
	};
	
	return {
	    downhdl : function(evt)
		{
		    var view = null;
			if(!evt){ view = W.tool.getedoc(this).parentWindow; evt = view.event; } else view = evt.view;
			var tget = evt.srcElement || evt.target;
			if( tget.id == 'xbtn' ) return;
			
			lacoor = { x : evt.screenX, y : evt.screenY };
			curpos =
			{
			    x : parseInt( W.tool.getestyle( frameElement, 'left' ), 10 ),
				y : parseInt( W.tool.getestyle( frameElement, 'top' ), 10 )
			};
			
			for( var i = 0; i < regwin.length; i++ )
			{
			    W.tool.addevt( regwin[i].document, 'mousemove', dragmovehdl );
				W.tool.addevt( regwin[i].document, 'mouseup', draguphdl );
			}
			
			if(evt.preventDefault) evt.preventDefault(); else evt.returnValue = false;
		},
		
		reghdl : function(w){ regwin.push(w); }
	};
}();	

(function()
{
	window.setokbtn = function(s)
	{
	    $('obtn').style.visibility = ( s ? '' : 'hidden' );
	};
	
	window.init = function()
	{
	    recontze(); $('throbber').style.visibility = ''; loadbtnevt(); loadinnfrm();
		if(W.binfo.ie) window.document.onmousedown = setop; else window.onmousedown = setop;
		var tite = $('dtit'); tite.onmousedown = drag.downhdl; drag.reghdl(window); drag.reghdl(A().twon);
		W.tool.disctmenu(document); if( /http/.test(A().page) ) $('throbber').style.visibility = 'hidden';
	};
	
	var setop = function(evt)
	{
		if(!evt) evt = event || this.parentWindow.event;
		W.tool.ststyle( frameElement, {'zIndex':parseInt(W.bzi,10) + 1} );
		W.bzi = frameElement.style.zIndex; evt.cancelBubble = true;
	};

	var loadinnfrm = function()
	{
		var s = /http/.test(A().page) ? '' : ' style="visibility:hidden;" ';
		$('dinner').innerHTML = '<iframe id="frmain" src="' + A().page + '" name="frmain" frameborder="0" ' +
		                        'width="100%" height="100%" scrolling="auto"' + s + 'allowtransparency="true"><\/iframe>';
	};
	
	window.loadinndlg = function()
	{
	    if( !frameElement.parentNode ) return null;
		var frmain = $('frmain'), innwin = frmain.contentWindow, inndoc = innwin.document;
		$('throbber').style.visibility = 'hidden'; frmain.style.visibility = '';
		if(W.binfo.ie) inndoc.onmousedown = setop; else innwin.onmousedown = setop;
		W.tool.disctmenu(inndoc); drag.reghdl(innwin); innwin.focus(); return W;
	};
	
	window.ok = function()
	{
	    var frm = window.frames['frmain'];
		if( frm.ok && frm.ok() ) closedlg(); else frm.focus();
	};
	window.cancel = function(){ return closedlg(); };
	
	window.closedlg = function()
	{
	    if( $('frmain') ) $('frmain').src = W.tool.getvoid();
		$('throbber').style.visibility = 'hidden'; W.lhgdialog.closdlg(window);
	};
	
	var loadbtnevt = function()
	{
	    $('xbtn').onmouseover = function(){ this.style.backgroundPosition = '0 -19px'; };
		$('cbtn').onmouseout = $('obtn').onmouseout = $('xbtn').onmouseout = function(){ this.style.backgroundPosition = '0 0'; };
		$('obtn').onmouseover = $('cbtn').onmouseover = function(){ this.style.backgroundPosition = '0 -21px'; };
		$('tc').innerHTML = '<span>' + A().tit + '</span>';
	};
})();
	</script>
</head>

<body onload="init();">
    <div id="contain" class="contain">
	    <div id="dtit" class="dlgtit">
		    <div id="tl"></div><div id="tc"></div><div id="tr"></div>
			<div id="xbtn" onclick="cancel();"></div>
		</div>
		<div id="dinner" class="dlginner"></div>
		<div id="dfoot" class="dlgfoot">
		    <div id="bl"></div><div id="bc"></div><div id="br"></div>
			<div id="cbtn" onclick="cancel();"><span>取 消</span></div>
			<div id="obtn" style="visibility:hidden;" onclick="ok();"><span>确 定</span></div>
		</div>
	</div>
	<div id="throbber" style="position:absolute;visibility:hidden;">正在加载窗口内容，请稍等....</div>
</body>
</html>